<?php

namespace App;

use App\Services\cityService;
use DateTimeInterface;
use Illuminate\Database\Eloquent\Model;

class Address extends Model
{
    //
    protected $fillable=['uid','province','city','area','detail','phone_number','default','name'];
    protected $appends=[
        'province_text','city_text','area_text'
    ];
    public function getProvinceTextAttribute()
    {
        $cityService=new cityService();
        $name=$cityService->getName($this->province);
        return $name;
    }
    public function getCityTextAttribute()
    {
        $cityService=new cityService();
        $name=$cityService->getName($this->city);
        return $name;
    }
    public function getAreaTextAttribute()
    {
        $cityService=new cityService();
        $name=$cityService->getName($this->area);
        return $name;
    }
    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }
}
